#include <iostream>
#include <vector>
#include <algorithm>

//理解递归过程
int get_maxvalue(std::vector<int> &arr, int left, int right)
{
	if (left == right)
	{
		return arr[left];
	}
	int mid = left + ((right - left) >> 1);
	int leftMax = get_maxvalue(arr, left, mid);
	int rightMax = get_maxvalue(arr, mid + 1, right);
	return leftMax > rightMax ? leftMax : rightMax;
		
}
int main()
{
	std::vector<int> arr{3,4,5,3,1,7,8,7,0,13,22,4,1,2,6,7382,33,2231,312312,4341,3131,1231241,1231232,122,3213,132312,3124,5754,7765,32423,4654,234234,23342,345,757,87,980};
	int max_value = get_maxvalue(arr, 0, arr.size() - 1);
	
	std::cout << "max_value = " << max_value << "==" << *max_element(arr.begin(), arr.end()) << std::endl;
	return 0;
}